import 'package:architecture/os_size.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:study_demo/ui/note/note_detail_controller.dart';

class NoteDetailPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GetX<NoteDetailController>(
        init: NoteDetailController(),
        builder: (controller) {
          return Scaffold(
              appBar: AppBar(title: Text('flutter命令')),
              body: ListView.separated(
                itemCount: controller.commands.length,
                itemBuilder: (context, index) {
                  return GestureDetector(
                    onTap: () {},
                    child: itemLayout(index, controller),
                  );
                },
                separatorBuilder: (context, index) {
                  return Divider(
                    height: 3,
                    color: Colors.transparent,
                  );
                },
              ));
        });
  }

  itemLayout(int index, NoteDetailController controller) {
    final item = controller.commands[index];
    return Container(
        alignment: Alignment.centerLeft,
        padding: EdgeInsets.fromLTRB(15, 0, 20, 0),
        height: 30,
        width: windowWidth * 0.35,
        child: Row(
          children: [
            Text(
              item.command!,
              style: TextStyle(
                  color: Colors.blueAccent, fontWeight: FontWeight.bold),
            ),
            SizedBox(
              width: 30,
            ),
            Text(
              item.desc!,
              style: TextStyle(color: Colors.black),
            ),
          ],
        ));
  }
}
